import request from '@/utils/request'

// 获取缴费列表
export function fetchPositions(marketId, type) {
    const data = {marketId, type}
    return request({
      url: 'api/v2/backend/position/index',
      method: 'post',
      data
    })
  }

export function addNewFloor(marketId, name) {
  var parentId = 0
  var type = 0
  const data = {marketId, name, type, parentId}
  return request({
    url: 'api/v2/backend/position/add',
    method: 'post',
    data
  })
}

export function addNewArea(marketId, parentId, name) {
  var type = 1
  const data = {marketId, name, type, parentId}
  return request({
    url: 'api/v2/backend/position/add',
    method: 'post',
    data
  })
}

export function editFloor(posId, marketId, name) {
  var parentId = 0
  var type = 0
  const data = {posId, marketId, name, type, parentId}
  return request({
    url: 'api/v2/backend/position/edit',
    method: 'post',
    data
  })
}

export function editArea(posId, marketId, parentId, name) {
  var type = 0
  const data = {posId, marketId, name, type, parentId}
  return request({
    url: 'api/v2/backend/position/edit',
    method: 'post',
    data
  })
}

export function deletePosition(posId, marketId) {
  const data = {posId, marketId}
  return request({
    url: 'api/v2/backend/position/del',
    method: 'post',
    data
  })
}

export function fetchFloorsSelector(marketId){
  const data = {marketId}
  return request({
    url: 'api/v2/backend/position/public',
    method: 'post',
    data
  })
}